
<template>
  选择批次：
  <a-select
      v-model:value="selectExperimentalBatch"
      style="width: 120px;margin-right: 30px">
    <a-select-option v-for="(item,index) in existingExperimentBatch" :key="index" :value="item">{{ item }}</a-select-option>
  </a-select>
  <a-form style="margin-top: 20px">
    <a-form-item
        label="实验批次"
        class="inputStyle"
        v-if="selectExperimentalBatch==='新建批次'">
      <a-input v-model:value="experimentalBatchForm.experimentalBatch" />
    </a-form-item>
    <a-form-item
        label="工艺备注"
        class="inputStyle">
      <a-textarea  v-model:value="experimentalBatchForm.processNote" rows="3"></a-textarea>
    </a-form-item>
    <a-form-item
        label="成分信息"
        class="inputStyle">
      <a-space direction="horizontal">
        <a-select
        v-model:value="experimentalBatchForm.componentInformationType"
        style="width: 90px;margin-right: 30px">
          <a-select-option value="xlsx">xlsx</a-select-option>
          <a-select-option value="csv">csv</a-select-option>
          <a-select-option value="xls">xls</a-select-option>
          <a-select-option value="D模型">D模型</a-select-option>
          <a-select-option value="D模型1">D模型1</a-select-option>
        </a-select>
        <a-upload :before-upload="addComponentInformationFileToStore">
          <a-button>
            选择本地文件
          </a-button>
        </a-upload>
      </a-space>
    </a-form-item>

    <a-form-item
        label="加工成型"
        class="inputStyle">
      <a-space direction="horizontal">
        <a-select
            v-model:value="experimentalBatchForm.processFormingType"
            style="width: 90px;margin-right: 30px">
          <a-select-option value="xlsx">xlsx</a-select-option>
          <a-select-option value="csv">csv</a-select-option>
          <a-select-option value="xls">xls</a-select-option>
          <a-select-option value="D模型">D模型</a-select-option>
          <a-select-option value="D模型1">D模型1</a-select-option>
        </a-select>
        <a-upload :before-upload="addProcessFormingFileToStore">
          <a-button>
            选择本地文件
          </a-button>
        </a-upload>
      </a-space>
    </a-form-item>

<!--    <a-form-item-->
<!--        label="熔炼数据"-->
<!--        class="inputStyle">-->
<!--      <a-space direction="horizontal">-->
<!--        <a-select-->
<!--            v-model:value="experimentalBatchForm.smeltingDataType"-->
<!--            style="width: 90px;margin-right: 30px">-->
<!--          <a-select-option value="xlsx">xlsx</a-select-option>-->
<!--          <a-select-option value="csv">csv</a-select-option>-->
<!--          <a-select-option value="xls">xls</a-select-option>-->
<!--          <a-select-option value="D模型">D模型</a-select-option>-->
<!--          <a-select-option value="D模型1">D模型1</a-select-option>-->
<!--        </a-select>-->
<!--        <a-upload>-->
<!--          <a-button>-->
<!--            选择本地文件-->
<!--          </a-button>-->
<!--        </a-upload>-->
<!--      </a-space>-->
<!--    </a-form-item>-->

    <a-form-item
        label="热处理信息"
        style="padding: 0 33vw 0 32vw;">
      <a-space direction="horizontal">
        <a-select
            v-model:value="experimentalBatchForm.heatTreatmentInformationType"
            style="width: 90px;margin-right: 30px">
          <a-select-option value="xlsx">xlsx</a-select-option>
          <a-select-option value="csv">csv</a-select-option>
          <a-select-option value="xls">xls</a-select-option>
          <a-select-option value="D模型">D模型</a-select-option>
          <a-select-option value="D模型1">D模型1</a-select-option>
        </a-select>
        <a-upload :before-upload="addHeatTreatmentInformationFileToStore">
          <a-button>
            选择本地文件
          </a-button>
        </a-upload>
      </a-space>
    </a-form-item>

    <a-space direction="horizontal" size="large">
      <a-button type="primary" @click="nextStepToDataUpload">下一步</a-button>
      <a-button type="primary" danger>取消</a-button>
    </a-space>
  </a-form>
</template>

<script>
export default {
  name: "DataInfoEnterOfExperimentalBatch",
  data(){
    return{
      selectExperimentalBatch:"新建批次",
      // existingExperimentBatch:["新建批次","第一批次","第二批次","第三批次"],
      experimentalBatchForm:{
        experimentalBatch:"",  //批次的名称
        processNote:"",   //批次的简短描述
        componentInformationType:"xlsx",  //成分信息xls文件
        processFormingType:"xlsx",   //加工成型信息xls文件
        smeltingDataType:"xlsx",   //熔炼数据xls文件
        heatTreatmentInformationType:"xlsx"   //热处理信息xls文件
      },
    }
  },

  methods:{
    ////跳转到下一页面(数据上传页面)
    nextStepToDataUpload(){
      sessionStorage.setItem("currentStep","2");
      const experimentalBatchFormString=JSON.stringify(this.experimentalBatchForm);
      sessionStorage.setItem("experimentalBatchForm",experimentalBatchFormString);

      // 打印构造的批次表信息到控制台
      console.log("构造的批次表信息:", this.experimentalBatchForm);
      this.$router.push("/DataInfoEnterOfDataUpload")
    },

    //向store中存储选中的文件
    //1.成分信息文件
    addComponentInformationFileToStore(file,fileList){
      const uploadObject={
        fileName:"COMPONENT_INFORMATION",
        fileContent:file
      }
      this.$store.commit('addFile',uploadObject);
      console.log("File uploaded successfully!"); // 添加成功消息
      console.log(this.$store.getters.getAllFiles)
      return false;
    },
    //2.加工成型文件
    addProcessFormingFileToStore(file,fileList){
      const uploadObject={
        fileName:"PROCESS_FORMING",
        fileContent:file
      }
      this.$store.commit('addFile',uploadObject);
      console.log(this.$store.getters.getAllFiles)
      return false;
    },
    //3.热处理信息文件
    addHeatTreatmentInformationFileToStore(file,fileList){
      const uploadObject={
        fileName:"HEAT_TREATMENT_INFORMATION",
        fileContent:file
      }
      this.$store.commit('addFile',uploadObject);
      console.log(this.$store.getters.getAllFiles)
      return false;
    }
  }
}
</script>

<style scoped>
.inputStyle{
  padding: 0 32vw 0 32vw;
}
</style>